package nccloud.web.gl.reckoning.action;

import java.util.Map;

import nc.bs.swjw.itf.ISwjwExcelImportService;
import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.core.io.WebFile;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.pubitf.ampub.common.excelimport.ImportFile;

public class UploadSWJWAction implements ICommonAction {

	@Override
	public Object doAction(IRequest request) {

		Map<String, String[]> param = request.readParameters();
		String queryDate = param.get("queryDate")[0];
		String pk_accountingbook = param.get("pk_accountingbook")[0];

		//		String queryString = para.toString();
		//		String queryDate = queryString.substring(queryString.indexOf("queryDate=") + 10, queryString.indexOf(","));
		//		String pk_accountingbook = queryString.substring(queryString.indexOf("pk_accountingbook=") + 18, queryString.indexOf("}"));;

		ImportFile fileInfo = null;
		try {
			fileInfo = ServiceLocator.find(ISwjwExcelImportService.class).swjwExcelImport(pk_accountingbook, queryDate);
		} catch (Exception e) {
			ExceptionUtils.wrapException(e);
		}
		WebFile webfile = null;
		if (null != fileInfo) {
			webfile = new WebFile(fileInfo.getFileName(), fileInfo.getInputStream());
		}
		return webfile;
	}


}
